import ElementPlus from 'element-plus';
import 'element-plus/dist/index.css';
import { createApp, reactive } from 'vue';
import { createPinia } from 'pinia';
import router from './router/index';
import App from './App.vue';
import svgIcon from './components/icons/index';
import '@/styles/index.scss'; // global css
import 'virtual:svg-icons-register';
import { directives } from '@/system/directives';
import './system/sysConsts';
import locale from 'element-plus/dist/locale/zh-cn.mjs'; //如果是vite构建，引入部分会爆红，可以在vite-env.d.ts中declare一下
import 'handsontable/styles/handsontable.min.css';
import 'handsontable/styles/ht-theme-main.min.css';
const app = createApp(App);

const pinia = createPinia();
app.use(pinia);
window.pinia = pinia;

import * as ElementPlusIconsVue from '@element-plus/icons-vue';
import { globalMixins } from '@/system/mixins/globalMixins';

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component);
}

// '' | 'small' | 'default' | 'large'
const globalConfig = reactive({
    size: 'large',
    locale,
});
app.provide('globalConfig', globalConfig);
app.use(ElementPlus, globalConfig);
app.mixin(globalMixins);
directives(app); // 指令
app.use(svgIcon);
app.use(router);
app.mount('#app');
